package cn.fbs.controller;

import cn.fbs.service.DataStatisticService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 安逸
 * @date 2021/1/27 - 12:02
 **/
@Api(tags = "数据统计")
@RestController
@RequestMapping("dataStatistic")
public class DataStatisticController {
    @Autowired
    private DataStatisticService dataStatisticService;

//    @ApiOperation("工作量统计")
//    @GetMapping("/queryWorkStatistics")
//    public ResponseEntity<List<Map<String,Object>>> queryWorkStatistics(){
//        return ResponseEntity.ok(dataStatisticService.queryWorkStatistics());
//    }

//    @ApiOperation("类别统计")
//    @GetMapping("/queryTypeStatistics")
//    public  ResponseEntity<List<Map<String,Object>>> queryTypeStatistics(){
//        return ResponseEntity.ok(dataStatisticService.queryTypeStatistics());
//    }



    @ApiOperation("根据标签组进行统计")
    @GetMapping("/labelStatistics")
    public  ResponseEntity<List<Map<String,Object>>> labelStatistics(){
        return ResponseEntity.ok(dataStatisticService.LabelStatistics());
    }

    @ApiOperation("工作量统计-根据用户进行统计")
    @GetMapping("/userStatistics")
    public  ResponseEntity<List<HashMap>> userStatistics(){
        return ResponseEntity.ok(dataStatisticService.userStatistics());
    }

    @ApiOperation("根据时间进行统计")
    @GetMapping("/timeStatistics")
    public  ResponseEntity<Map<String,Object>> timeStatistics(){
        return ResponseEntity.ok(dataStatisticService.timeStatistics());
    }

    @ApiOperation("根据目标进行统计")
    @GetMapping("/targetStatistics")

    @ApiImplicitParams({
            @ApiImplicitParam(name = "zbnm",value = "当前目标的装备内码"),
            @ApiImplicitParam(name = "source", value = "来源")}
    )
    ResponseEntity<Map<String,Object>> targetStatistics(
            @RequestParam(value = "zbnm") String zbnm,
            @RequestParam(value = "source")String source){
        return ResponseEntity.ok(dataStatisticService.targetStatistics(zbnm,source));
    }

    @ApiOperation("类别统计-统计系统中图像，视频，资料的占比")
    @GetMapping("/sumStatistics")
    public  ResponseEntity<List<Map<String, Object>>> sumStatistics(){
        return ResponseEntity.ok(dataStatisticService.sumStatistics());
    }


    @ApiOperation("根据标签组的ID，统计当前标签组下的打标签占比")
    @GetMapping("/getGroupLableStatistics")
    @ApiImplicitParam(name = "groupId",value = "当前标签组的ID")
    public List<Map<String, Object>> getGroupLableStatistics(String groupId){
        List<Map<String, Object>> list = dataStatisticService.getGroupLableStatistics(groupId);
        return list;
    }

    @ApiOperation("根据类型,获取标签组")
    @GetMapping("/getLabelGroupByType")
    @ApiImplicitParam(name = "type",value = "当前标签组的类型 0.是标签统计， 1.是属性统计",example = "0")
    public List<Map<String,Object>> getLabelGroupByType(Integer type){
        List<Map<String,Object>> list =  dataStatisticService.getLabelGroupByType(type);
        return list;
    }

}
